"""
根据传入的名称以及config构建retrieve 处理类
"""
from retrieve.base_retrieve import BaseRetrieve
from retrieve.text_retrieve import TextRetrieve
from retrieve.tag_retrieve import TagRetrieve
from retrieve.history_retrieve import HistoryRetrieve


class RetrieveFactory:
    @classmethod
    def create_service(cls, config):
        service = None
        if config["name"] == "base_retrieve":
            service = BaseRetrieve(config)
        elif config["name"] == "text_retrieve":
            service = TextRetrieve(config)
        elif config["name"] == "tag_retrieve":
            service = TagRetrieve(config)
        elif config["name"] == "history_retrieve":
            service = HistoryRetrieve(config)

        if not service:
            print("init retrieve service %s failed " % config["name"])
        return service

